﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        public DataSet QueryGPACK(DataRow dwData, int option)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:                  
                    break;
                case 2:
                    or1.CommandText = "SELECT G.* FROM GPACK G JOIN VVLIEF V ON GPAMANDANT=VVMANDANT AND GPALIEFSCH=VVLIEFSCH JOIN VVTLIEF T ON V.VVMANDANT=VVTMANDANT AND VVLIEFSCH=VVTLIEFSCH"
               + " WHERE VVTMANDANT=:VVTMANDANT AND VVTAUFKRS =:VVTAUFKRS AND VVTAUFLFD=:VVTAUFLFD";
                    or1.Parameters.Add("VVTMANDANT", OracleType.NVarChar).Value = dwData["VVTMANDANT"].ToString();
                    or1.Parameters.Add("VVTAUFKRS", OracleType.NVarChar).Value = dwData["VVTAUFKRS"].ToString();
                    or1.Parameters.Add("VVTAUFLFD", OracleType.NVarChar).Value = dwData["VVTAUFLFD"].ToString();  
                    break; 
                case 3:
                    or1.CommandText = "SELECT VVLIEFSCH,P.* FROM GPACK P  JOIN VVLIEF ON VVLIEFSCH=GPALIEFSCH WHERE  VVNEUDAT>='" + dwData["DSTART"].ToString() + "' AND VVNEUDAT<='" + dwData["DEND"].ToString() + "' AND VVSTATUS IN (" + dwData["C20"].ToString() + ")"; 
                    break;                     
                default:
                    break;
            } 
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "GPACK";
            Return = Result;
            return Return;
        }
       
    }
}
